<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', 'Index\IndexController@index');
// 认证路由...
Route::get('login', 'Auth\AuthController@admin');
Route::post('login', 'Auth\AuthController@postAdmin');
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// 注册路由...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

// 密码重置链接的路由...
Route::get('password/email', 'Auth\PasswordController@getEmail');
Route::post('password/email', 'Auth\PasswordController@postEmail');

// 密码重置的路由...
Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
Route::post('password/reset', 'Auth\PasswordController@postReset');

Route::group(['prefix' => 'index', 'namespace' => 'Index'], function () {
    Route::get('/', 'IndexController@index');
    Route::get('/buy', 'IndexController@buy');
    Route::get('/sell', 'IndexController@sell');
    Route::get('/show', 'IndexController@show');
    Route::get('/json', 'IndexController@json');
    Route::post('/search', 'IndexController@search');
});
Entrust::routeNeedsRole('admin*', 'admin', Redirect::to('/login'));

Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
    Route::get('/', 'IndexController@index');
    Route::get('/maptest', 'IndexController@maptest');
    Route::get('/search', 'IndexController@search')->name('admins');
    Route::get('/create', 'IndexController@create');
    Route::get('/edit', 'IndexController@edit');
    Route::get('/detail', 'IndexController@detail');
    Route::get('/test', 'IndexController@test');
    Route::get('/subscribe', 'IndexController@subscribe');
    Route::get('/publish', 'IndexController@publish');
});
Route::get('publish', function () {
    // 路由逻辑...
    \Redis::publish('test-channel', json_encode(['foo' => 'bar']));
});
